package cz.idsv.web.mvc.model.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * Address Entity.
 * 
 * @author Jan Borzensky
 */

@Entity(name = "Address")
@Table(name = "ADDRESS")
public class AddressEntity implements Serializable {

	private static final long serialVersionUID = -8712872333957386182L;
    
	private Integer id = null;
	private String city = null;
	private String street = null;
	private String streetNumber = null;
	private String postNumber = null;

	/**
	 * Gets id (primary key).
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	/**
	 * Sets id (primary key).
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * Gets type.
	 */
	public String getCity() {
		return city;
	}

	/**
	 * Sets type.
	 */
	@Column(name = "CITY")
	public void setCity(String city) {
		this.city = city;
	}
	

	/**
	 * Gets type.
	 */
	public String getStreet() {
		return street;
	}
	/**
	 * Sets type.
	 */
	@Column(name = "STREET")
	public void setStreet(String street) {
		this.street = street;
	}

	/**
	 * Gets type.
	 */
	public String getPostNumber() {
		return postNumber;
	}
	/**
	 * Sets type.
	 */
	@Column(name = "POSTNUMBER")
	public void setPostNumber(String postNumber) {
		this.postNumber = postNumber;
	}
	/**
	 * Gets type.
	 */
	public String getStreetNumber() {
		return streetNumber;
	}
	/**
	 * Sets type.
	 */
	@Column(name = "STREETNUMBER")
	public void setStreetNumber(String streetNumber) {
		this.streetNumber = streetNumber;
	}
	/**
	 * Returns a string representation of the object.
	 */
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();

		sb.append(this.getClass().getName() + "-");
		sb.append("  id=" + id);
		sb.append("  city=" + city);
		sb.append("  street=" + street);
		sb.append("  streetNumber=" + streetNumber);
		sb.append("  postNumber=" + postNumber);

		return sb.toString();
	}

	/**
	 * Returns a hash code value for the object.
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((city == null) ? 0 : city.hashCode());
		result = prime * result + ((street == null) ? 0 : street.hashCode());
		result = prime * result + ((streetNumber == null) ? 0 : streetNumber.hashCode());
		result = prime * result + ((postNumber == null) ? 0 : postNumber.hashCode());
		result = prime * result
				+ ((city == null) ? 0 : city.hashCode());
		result = prime * result
				+ ((street == null) ? 0 : street.hashCode());
		result = prime * result
				+ ((streetNumber == null) ? 0 : streetNumber.hashCode());
		result = prime * result
				+ ((postNumber == null) ? 0 : postNumber.hashCode());

		return result;
	}

	/**
	 * Indicates whether some other object is equal to this one.
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final AddressEntity other = (AddressEntity) obj;

		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		
		if (city == null) {
			if (other.city != null) {
				return false;
			}
		} else if (!city.equals(other.city)) {
			return false;
		}
		if (street == null) {
			if (other.street != null) {
				return false;
			}
		} else if (!street.equals(other.street)) {
			return false;
		}
		if (streetNumber == null) {
			if (other.streetNumber != null) {
				return false;
			}
		} else if (!streetNumber.equals(other.streetNumber)) {
			return false;
		}
		if (postNumber == null) {
			if (other.postNumber != null) {
				return false;
			}
		} else if (!postNumber.equals(other.postNumber)) {
			return false;
		}

		return true;
	}

}
